#ifndef _Rect_H_
#define _Rect_H_

#pragma once
#include "Primitive.h"

class Rect: public Primitive {
private:
	Vector3 position, normal;
	Vector3 a, b;
	Double aLengthSqr, bLengthSqr;

public:
	Rect(Vector3 &position, Vector3 &a, Vector3 &b) : position(position), a(a), b(b),
		normal(crossProduct(a, b)), aLengthSqr(a.lengthSqr()), bLengthSqr(b.lengthSqr()) {}
	~Rect() {};

	bool intersect(const Ray &ray, IntersectResult &result) const;
	bool intersectP(const Ray &ray) const;

	inline static string getName() {
		return string("Rect");
	}
	string str() const;
};

#endif // _Rect_H_